package cn.xtcode.domain.trade.service.lock.factory;

import cn.xtcode.domain.trade.model.entity.GroupBuyActivityEntity;
import cn.xtcode.domain.trade.model.entity.TradeLockRuleCommandEntity;
import cn.xtcode.domain.trade.model.entity.TradeLockRuleFilterBackEntity;
import cn.xtcode.domain.trade.service.lock.filter.ActivityUsabilityRuleFilter;
import cn.xtcode.domain.trade.service.lock.filter.UserTakeLimitRuleFilter;
import cn.xtcode.types.design.framework.link.model2.LinkArmory;
import cn.xtcode.types.design.framework.link.model2.chain.BusinessLinkedList;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

/**
 * @Author xt-code
 * @Description:
 * @Create 2025/5/10 22:32
 */
@Slf4j
@Service
public class TradeRuleFilterFactory {

    @Bean("tradeRuleFilter")
    public BusinessLinkedList<TradeLockRuleCommandEntity, TradeRuleFilterFactory.DynamicContext, TradeLockRuleFilterBackEntity>
    tradeRuleFilter(ActivityUsabilityRuleFilter activityUsabilityRuleFilter,UserTakeLimitRuleFilter userTakeLimitRuleFilter) {
        LinkArmory<TradeLockRuleCommandEntity, TradeRuleFilterFactory.DynamicContext, TradeLockRuleFilterBackEntity> linkArmory =
                new LinkArmory<>("交易规则过滤链条", activityUsabilityRuleFilter, userTakeLimitRuleFilter);

        return linkArmory.getLogicLink();
    }

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class DynamicContext {
        private GroupBuyActivityEntity groupBuyActivity;
    }
}
